<?php

/**
 * Paciente form base class.
 *
 * @method Paciente getObject() Returns the current form's model object
 *
 * @package    dentist
 * @subpackage form
 * @author     Brus
 */
abstract class BasePacienteForm extends BaseFormPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'           => new sfWidgetFormInputHidden(),
      'nombre'       => new sfWidgetFormInputText(),
      'apellido'     => new sfWidgetFormInputText(),
      'cedula'       => new sfWidgetFormInputText(),
      'direccion'    => new sfWidgetFormInputText(),
      'telefono'     => new sfWidgetFormInputText(),
      'correo'       => new sfWidgetFormInputText(),
      'fecha_nac'    => new sfWidgetFormDate(),
      'fecha_ing'    => new sfWidgetFormDate(),
      'fecha_baja'   => new sfWidgetFormDate(),
      'nro_paciente' => new sfWidgetFormInputText(),
      'activo'       => new sfWidgetFormInputCheckbox(),
      'usuario_id'   => new sfWidgetFormPropelChoice(array('model' => 'Usuario', 'add_empty' => false)),
      'created_at'   => new sfWidgetFormDateTime(),
      'updated_at'   => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'           => new sfValidatorChoice(array('choices' => array($this->getObject()->getId()), 'empty_value' => $this->getObject()->getId(), 'required' => false)),
      'nombre'       => new sfValidatorString(array('max_length' => 50)),
      'apellido'     => new sfValidatorString(array('max_length' => 50)),
      'cedula'       => new sfValidatorString(array('max_length' => 50)),
      'direccion'    => new sfValidatorString(array('max_length' => 255)),
      'telefono'     => new sfValidatorString(array('max_length' => 50)),
      'correo'       => new sfValidatorString(array('max_length' => 255)),
      'fecha_nac'    => new sfValidatorDate(),
      'fecha_ing'    => new sfValidatorDate(),
      'fecha_baja'   => new sfValidatorDate(array('required' => false)),
      'nro_paciente' => new sfValidatorInteger(array('min' => -2147483648, 'max' => 2147483647, 'required' => false)),
      'activo'       => new sfValidatorBoolean(),
      'usuario_id'   => new sfValidatorPropelChoice(array('model' => 'Usuario', 'column' => 'id')),
      'created_at'   => new sfValidatorDateTime(array('required' => false)),
      'updated_at'   => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorPropelUnique(array('model' => 'Paciente', 'column' => array('cedula'))),
        new sfValidatorPropelUnique(array('model' => 'Paciente', 'column' => array('correo'))),
      ))
    );

    $this->widgetSchema->setNameFormat('paciente[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Paciente';
  }


}
